<?php

require ("sharedResources.php");

$sid = '';
try {
	// We need a SID (session ID) in order to operate
	$sid = login ( 'admin', 'admin' );
	echo 'sid: ' . $sid . PHP_EOL;
	
	$doc ['language'] = 'en';
	$doc ['fileName'] = 'testContent.txt';
	$doc ['folderId'] = DEFAULT_WORKSPACE; // create the document in DEFAULT_WORKSPACE

	// Requested parameters 
	// (although they are not evaluated during document creation)
	$doc ['creatorId'] = 0;
	$doc ['dateCategory'] = 0;
	$doc ['docType'] = 0;
	$doc ['exportStatus'] = 0;
	$doc ['fileSize'] = 0;
	$doc ['id'] = 0;
	$doc ['immutable'] = 0;
	$doc ['indexed'] = 0;
	$doc ['lengthCategory'] = 0;
	$doc ['publisherId'] = 0;
	$doc ['signed'] = 0;
	$doc ['size'] = 0;
	$doc ['status'] = 0; // Status = 0: document unlocked	
	
	// This is new in 6.4	
	$doc ['published'] = 1;
	
	$content = 'Test Content';
	
	$createParams = array ('sid' => $sid, 'document' => $doc, 'content' => $content );
	
	// Result is the document object of the new created document or a SoapFault exception
	$result = $documentClient->create ( $createParams );
	print_r ( $result );
	
	echo PHP_EOL . 'Document created with Title: ' . $result->document->title . '; ID: ' . $result->document->id;
	echo PHP_EOL . 'Document fileName: ' . $result->document->fileName . '; size: ' . $result->document->fileSize;
	echo PHP_EOL . 'Document date: ' . $result->document->date;
	//unset ( $documentClient );
} catch ( SoapFault $e ) {
	print_r ( $e );
}

// Always we need to logout in order to release connection slot
logout ( $sid );
?> 
